

/**
 * @author Carlos
 * @version 1.0
 * @created 09-oct-2013 05:23:44 p.m.
 */
using System.Collections.Generic;
using System;
using GameEngine.Scenes;

namespace GameEngine.animations
{
    public class DetailAnimationCharacter : DetailAnimation
    {

        private CharacterAnimations characterAnimations;
        public CharacterAnimations CharacterAnimations
        { 
            get{ return characterAnimations; }
            set
            {
                characterAnimations = value;
                updateFromUntilFrame();
            }
        }

        public void updateFromUntilFrame() 
        {
            int animRow = ((int)characterAnimations);
            fromFrame = animRow * animation.framesX;
            untilFrame = fromFrame + animation.framesX - 1;
            if (currentFrame < fromFrame || currentFrame > untilFrame)
                currentFrame = fromFrame + (currentFrame % animation.framesX);
        }

        #region Constructors
        //TODO Change the way to get the RECT animation in a matematical way
        public DetailAnimationCharacter(Actor actor, string name, Animation animation, int freqFrame, CharacterAnimations position)
            : base(actor, name, animation, freqFrame)
        {
            this.CharacterAnimations = position;
        }
        public DetailAnimationCharacter(Actor actor, string name, Animation animation, int freqFrame, int fromFrame, int untilFrame)
            : base(actor, name, animation, freqFrame, fromFrame, untilFrame)
        { }
        public DetailAnimationCharacter(Actor actor, string name, Animation animation, int freqFrame)
            : base(actor, name, animation, freqFrame)
        { }
        public DetailAnimationCharacter(Actor actor, string name, Animation animation)
            : base(actor, name, animation)
        { }
        public DetailAnimationCharacter() //only for cloning usage
            : base() 
        { }
        #endregion

        #region ICloneable Members

        public override object Clone()
        {
            DetailAnimationCharacter newDetailAnimationCharacter = (DetailAnimationCharacter)base.Clone();
            newDetailAnimationCharacter.characterAnimations = this.characterAnimations;
            return newDetailAnimationCharacter;
        }

        #endregion

    }
}